package vsion.demo.service.safty.impl;

import vsion.demo.model.InfoCustomer;
import vsion.demo.dao.safty.InfoCustomerDao;
import vsion.demo.service.safty.InfoCustomerService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (InfoCustomer)表服务实现类
 *
 * @author makejava
 * @since 2019-09-27 11:33:03
 */
@Service("infoCustomerService")
public class InfoCustomerServiceImpl implements InfoCustomerService {
    @Resource
    private InfoCustomerDao infoCustomerDao;

    /**
     * 通过ID查询单条数据
     *
     * @param cusId 主键
     * @return 实例对象
     */
    @Override
    public InfoCustomer queryById(Integer cusId) {
        return this.infoCustomerDao.queryById(cusId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<InfoCustomer> queryAllByLimit(int offset, int limit) {
        return this.infoCustomerDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param infoCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public InfoCustomer insert(InfoCustomer infoCustomer) {
        this.infoCustomerDao.insert(infoCustomer);
        return infoCustomer;
    }

    /**
     * 修改数据
     *
     * @param infoCustomer 实例对象
     * @return 实例对象
     */
    @Override
    public InfoCustomer update(InfoCustomer infoCustomer) {
        this.infoCustomerDao.update(infoCustomer);
        return this.queryById(infoCustomer.getCusId());
    }

    /**
     * 通过主键删除数据
     *
     * @param cusId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer cusId) {
        return this.infoCustomerDao.deleteById(cusId) > 0;
    }
}